package classes.form {
	import classes.Label;

	import flash.display.Sprite;
	import flash.events.MouseEvent;

	/**
	 * @author dennis
	 */
	public class Button extends Sprite {
		private const SUBMIT : String = "submit";
		private const RESET : String = "reset";

		public function Button() : void {
			this.buttonMode = true;
			this.mouseChildren = false;	
		}

		public function generate( form : Form, normal : * = undefined, hover : * = undefined, active : * = undefined, action : String = "submit" ) : void {
			if( normal && hover && active ) {
			} else {
				var bg : Sprite = new Sprite();
				bg.graphics.beginFill(0x333333);
				bg.graphics.drawRect(0, 0, 100, 15);
				bg.graphics.endFill();
				this.addChild(bg);
			}
			
			switch( action ) {
				case SUBMIT:
					this.addEventListener(MouseEvent.MOUSE_DOWN, form.submit);
					break;
					
				case RESET:
					this.addEventListener(MouseEvent.MOUSE_DOWN, form.reset);
					break;
			}
		}

		public function createLabel(text : String, color : uint = 0xFFFFFF) : void {
			var label : Label = new Label("Submit");
			label.generate(10, color, false);
			label.x = this.width / 2 - label.width / 2;
			this.addChild(label);
		}
	}
}
